﻿using System.Linq;
using Telerik.Windows.Controls.Diagrams;

namespace Samurai.WorkflowGraph.ShapeExtensions
{
    public static class ShapeExtensions
    {
        /// <summary>
        /// Determines whether the specified shape has children.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <returns>
        ///   <c>True</c> if the specified shape has children; otherwise, <c>false</c>.
        /// </returns>
        public static bool HasChildren(this RadDiagramShapeBase shape)
        {
            return shape != null && shape.OutgoingLinks.Any();
        }

        /// <summary>
        /// Determines whether the specified shape has parents.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <returns>
        ///   <c>True</c> if the specified shape has parents; otherwise, <c>false</c>.
        /// </returns>
        public static bool HasParents(this RadDiagramShapeBase shape)
        {
            return shape != null && shape.IncomingLinks.Any();
        }
    }
}
